/***************************************************************************
 *   This file is part of KLabeler                                         *
 *   Copyright (C) 2010 by Luca Bellonda                                   *
 *   lbellonda _at_ gmail.com                                              *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef UTILITY_H
#define UTILITY_H

#include <QString>
#include <QComboBox>
#include <QTableWidget>
#include <QListWidget>

class Utility : public QObject
{
    Q_OBJECT
private:
    Utility();

public:
    static void error(const QString& message);
    static void error(QWidget *parent, const QString & message);
    static void message(const QString& message);
    static void message(QWidget *parent, const QString & message);
    static bool askYN(QWidget *parent, const QString & message);

    // Specialized errors
    static void errorNoSel(QWidget *parent);
    static void errorOutOfMem(QWidget *parent);
    static void errorReadingUserSettings();
    static void errorSavingUserSettings();


    static QStringList normalizeTags(const QStringList &inputTags);


    //------
    static void showWaitCursor();
    static void restoreCursor();


    //-- utility
    static void selectComboValue(QComboBox *combo, const int value);
    static void addTagToSet(QTableWidget *table, const QString &tag);
    static void getListSet(QListWidget *list, QStringList &tags);
    static void getTableSet(QTableWidget *table, QStringList &tags);


    static bool decodeBoolean(const QString &str);
    static int decodeInt(const QString &str, const int defaultVale);

    static QString fromBase64(const QString &text);
    static QString toBase64(const QString &text);

    static QString getLocalDataDir(const QString &dataDirName);

};

#endif // UTILITY_H
